﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Service.Core.Interface;
using Tools;
using System.IO;
//using log4net.Config;
//using log4net;

namespace Web.Controllers
{
    public class BaseController : Controller
    {
        protected override void OnException(ExceptionContext filterContext)
        {
            //var logger = LogManager.GetLogger(typeof(BaseController));

            //logger.Error(filterContext.Exception);
            //logger.Error(filterContext.Exception.Data);
            //logger.Error(filterContext.Exception.StackTrace);
            // 标记异常已处理
            //filterContext.ExceptionHandled = true;
            // 跳转到错误页
            //filterContext.Result = new RedirectResult(Url.Action("Error", "Shared"));
        }

       

        public ActionResult RedirectError()
        {
            return new RedirectResult(Url.Action("Error", "Shared"));
        }

        public String JsonResult(IServiceResult result)
        {
            return JsonHelper.SerializeObject(result);
        }

        //private static void InitLog4Net()
        //{
        //    var logCfg = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config");
        //    XmlConfigurator.ConfigureAndWatch(logCfg);
        //}
    }
}